Skip to content

TR-1313: lore review follow-ups from TR-1189/TR-1191 - #7

Merged
ashish-bagri merged 3 commits into
mainfrom
factory/TR-1313
Nov 15, 2026
Merged

ashish-bagri merged 3 commits into
mainfrom
factory/TR-1313

Conversation

@ashish-bagri

Copy link
Copy Markdown
Member

Ticket: TR-1313 (review follow-ups from TR-1189/TR-1191).

Changes

  • Prune old index_runs: write_run deletes the runs of a source beyond the newest 50, never one that is going (not ended and not stale). Bounded by a timeout; a failure only logs.
  • One clock for the admin page: now in /v1/admin/overview (inside its snapshot) and /v1/admin/pushes comes from the database (SELECT now()), the clock that stamps updated_at and decides stale.
  • Timeout on lock ping/unlock/close: every query on the lock connection has QUERY_TIMEOUT (10 s); release() waits a bounded time and aborts the task; a failed or timed-out ping logs an error and ends the keepalive.
  • Indexed ref after a refused push: when index_commit answers NeedFull, the lore-indexed ref and the checkout go back to the DB's indexed commit.
  • Docs (docs/usage.md) updated for all four.

Checks (Docker, rust:1.95, pgvector pg17)

  • cargo fmt --all --check: clean
  • cargo clippy --all-targets -- -D warnings: clean
  • cargo test --all-targets: 693 passed, 2 failed, 4 ignored. The 2 failures are in tests/cli_search.rs and only happen in this arm64 Docker VM: onnxruntime writes a cpuid warning to stderr and the tests compare stderr exactly. The file is untouched here; CI on x86 is the check for those.
  • Each new test was proven by breaking the code it covers: pruning (P1, P2), database clock (D1), restore after a refused push (N1) and the lock timeouts as a whole (L3) all make the new tests fail. Removing only the release bound (L1) or only the ping timeout (L2) does not fail a test: the layers overlap (the unlock and close timeouts also bound the release), so one alone is redundant. Reported as is.

Assumptions

None new.

🤖 Generated with Claude Code

- prune index_runs: keep the newest 50 runs per source, never a running one
- admin overview and pushes use the database's clock for now
- timeouts on the lock connection's ping, unlock and close, and a bounded release
- a refused push restores the lore-indexed ref and the checkout to the indexed commit

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ashish-bagri

Copy link
Copy Markdown
Member Author

factory/review: changes (round 1) at 2ae3f3f

Reviewer: ashish-crew-reviewer

Blocking

  • F1 P2, src/repo/mod.rs:470. A refused push restores lore-indexed and the checkout to the wrong commit.
    • The branch runs only when locked_commit != source.indexed_commit. At that point the database holds B, the commit the lore index Job wrote, never A.
    • restore_indexed(paths, source.indexed_commit) restores to the stale pre-lock A. The ref is now behind the database rather than ahead of it.
    • The code comment ("so deep mode keeps reading what search serves") and docs/usage.md:174 ("put back at the indexed commit the database holds") both say it should match the database. tests/cli_index.rs:764 asserts A, which locks in the mismatch.
    • Fix: restore to locked_commit when cat-file -e <B>^{commit} finds it in the mirror, with A as the fallback, and assert B in the test. Otherwise, make the docs and comment say A and explain why.

Non-blocking (P3)

  • F2, lock.rs:177. Nothing tests that a ping error or timeout ends the keepalive task.
    • M6 (the timeout branch keeps looping) and M7 (the error branch keeps looping) both pass --test cli_index.
    • Together with the L1/L2 survivors, each bound masks the other: hold is capped near 3Q by its own timeouts, and release aborts at 3Q.
  • F3, lock.rs:134. Dropping the connection does not free the server's lock on a half-open link.
    • After an abort or a ping drop, Postgres keeps the session advisory lock until its own TCP keepalive notices (about 2 h by default), and the next lore index exits 3.
    • The reverse also happens: a ping that times out on a slow but live link frees the lock while this lore index keeps running.
    • Consider tcp_keepalives_* on the lock connection, or pg_terminate_backend(pid) from a fresh connection.
  • F4, lock.rs:93. connect and pg_try_advisory_lock have no timeout.
  • F5, progress.rs:42. The "has not ended" doc comment now sits above KEEP_RUNS_PER_SOURCE, and NOT_ENDED has lost its doc.
  • F6, tests/index_runs.rs. No test checks that a stale run inside the newest 50 is kept.
  • F7. PR TR-1192: central lore adopts a repo a Job indexed, without indexing again #6 also appends to tests/cli_index.rs. They conflict only there, so whichever merges second needs a rebase.

Verified (clean env through tares factory heavy, rust:1.95-trixie with its own pgvector pg17)

  • cargo fmt --all -- --check: ok. cargo clippy --all-targets -- -D warnings: clean.
  • cargo test --all-targets --no-fail-fast: 693 passed, 2 failed, 4 ignored. The 2 failures are tests/cli_search.rs:83 and :209, from the onnxruntime cpuid stderr warning on arm64. That is environmental.
  • Mutations caught: M5 (list_pushes takes now from Utc::now()) and M8 (the prune drops the going-run guard). Survived: M6 and M7 (F2).
  • Prune SQL read: with fewer than 50 runs it deletes nothing, it never deletes a fresh unfinished run, and a prune failure is only logged, after the insert.
  • A second-model challenge (Sonnet) ran on the diff and my draft findings.

Not verified

  • The x86 CI run.
  • Real NAT or load-balancer half-open behaviour.
  • Whether production server mirrors always hold B's objects when the Job and the server have different data dirs.

…review F1, F5, F6)

A push refused behind a `lore index` put the indexed ref and the checkout back at the commit the
push started from, which is behind what the database holds. It now restores to the commit the
database holds when this server's mirror has it, and to the start commit otherwise. Moves the
NOT_ENDED doc comment back to NOT_ENDED, and tests that a stale run inside the newest window is
kept.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ashish-bagri

Copy link
Copy Markdown
Member Author

factory/review: pass (round 2) at e82f6d2

Reviewer: ashish-crew-reviewer. Verdict recorded on Tares (TR-1313).

Earlier findings

  • F1 (P2, blocking): fixed. restore_indexed restores to the database's commit when the mirror has it, and falls back to the start commit otherwise. The code comment, docs/usage.md:174 and the test now agree.
  • F5, F6: fixed.
  • F2, F3, F4 (lock.rs), F7 (conflict with TR-1192: central lore adopts a repo a Job indexed, without indexing again #6 in tests/cli_index.rs, still there by git merge-tree): open, non-blocking.

Verified (tares factory heavy, rust:1.95-trixie, own pgvector:pg17 container)

  • cargo fmt --all -- --check: ok.
  • cargo clippy --all-targets -j 2 -- -D warnings: clean.
  • cargo test --all-targets --no-fail-fast -j 2: 695 passed, 2 failed, 4 ignored. The 2 failures are tests/cli_search.rs: the onnxruntime cpuid warning on the arm64 VM, environmental, file untouched.
  • Mutations, each restored:
    • Always restore to the DB commit: a_push_that_queued_behind_an_index_does_not_apply_its_stale_diff fails.
    • Inverted mirror check: both refused-push tests fail.
    • Stale run never pruned: a_stale_run_among_the_newest_is_kept fails.
  • The new test is not vacuous. B is fetched into the server mirror only after the push is parked on the row lock. Both the ref and the ghost.md checks tell A from B.
  • Second-model challenge (Sonnet) could not refute the pass.

New, non-blocking (P3)

  • F8 (src/repo/mod.rs:523): when the mirror lacks B, which is the common case, the ref is restored to A, behind the DB. That is documented. Refusals before the row-lock check (from_diff NeedFull, refresh failure, vanished tenant or source) never restore. This predates the PR.
  • F9 (src/repo/mod.rs:536): the ref moves before the checkout refresh, so a read-tree failure leaves the two apart. Refresh first, then move the ref.
  • F10 (tests/index_runs.rs:845): the lost writer's 5 s heartbeat can make the stale run fresh if the test stalls. That gives a spurious failure, never a false pass.

Not verified

  • The x86 cli_search run (CI only).
  • A real sync that fetched the Job's commit before a refused push.
  • lock.rs, which is unchanged this round.

@ashish-bagri

Copy link
Copy Markdown
Member Author

factory/review — pass (TR-1313, head e97a415, round 3)

Verdict: pass. This head merges main (a9fd41b, lore#6 TR-1192) into e82f6d2.

Verified

  • I checked the conflict resolution with git show --remerge-diff e97a4152. Hand edits are only in tests/cli_index.rs:
    • ._server_data becomes .server_data at two places.
    • Both sides' tests are kept (the proxy/keepalive tests and the tree_files/sync tests).
    • A closing } is added for a_keepalive_on_a_dead_connection_does_not_block_the_release.
    • Nothing else differs from the clean auto-merge.
  • Run in rust:1.95-trixie against pgvector pg17, on the head:
    • cargo fmt --all -- --check: clean.
    • cargo clippy --all-targets -- -D warnings: clean.
    • cargo test --all-targets --no-fail-fast: 700 passed, 2 failed, 4 ignored. The 2 failures are tests/cli_search.rs, which always fail on arm64.
    • cargo test --test cli_index: 17 passed.

Earlier findings

  • F7: fixed.
  • F2, F3, F4, F8, F9 and F10 are still open. They are P3 and do not block.

Not verified

  • The earlier rounds' mutations were not rerun, because the merge touched only tests.
  • Not run on amd64.

— ashish-crew-reviewer

@ashish-bagri
ashish-bagri merged commit ee59276 into main Nov 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant